{include file="common/head"/}

<style>
    .error{color: #f00;}
</style>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>
    {include file="common/left"}
    <div class="main-content">
        <div class="main-content-inner">
            {include file="common/header_nav"}
            <div class="page-content">
                <div class="page-header">
                    <h1>
                        您当前操作
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            编辑内容
                        </small>
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <form class="form-horizontal" role="form" name="myform" id="myform" method="post" action="{if condition="$actionName=='add'"}{:url('insert')}{else /}{:url('update')}{/if}">
                        {if condition="$info['id'] neq ''"}<input TYPE="hidden" name="id" value="{$info.id}">{/if}
                            {volist name="fields" id="r"}
                                {if condition="!empty($r['status'])"}
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label no-padding-right" for="{$r.field}">{$r.name}</label>
                                        <div class="col-sm-10 col-xs-12" id="box_{$r['field']}">
                                                {$r,input($r['field'])|getform=$form,###}
                                        </div>
                                    </div>
                                    <div class="space-4"></div>
                                {/if}
                            {/volist}
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button class="btn btn-info" type="submit">
                                        <i class="ace-icon fa fa-check bigger-110"></i>
                                        提交
                                    </button>

                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="ace-icon fa fa-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    {include file="common/foot" /}
</div>
<script type="text/javascript" src="__STATIC__/assets/js/region.js"></script>
<script type="text/javascript" src="__STATIC__/jquery.validate.js"></script>
<script>
    $(function(){
        $('#myform').ajaxForm({
            beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
            success: complete, // 这是提交后的方法
            dataType: 'json'
        });

        function checkForm(){
        }
        function complete(data){
            if(data.status==1){
                layer.alert(data.info, {icon: 6}, function(index){
                    layer.close(index);
                    if(data.url){
                        window.location.href=data.url;
                    }
                });
            }else{
                layer.alert(data.info, {icon: 5}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

    });

</script>
</body>
</html>